package com.chenyitun.cloudsystem.service.impl;


import com.chenyitun.cloudcommon.dto.SysLog;
import com.chenyitun.cloudcommon.utils.Query;
import com.chenyitun.cloudcommon.utils.R;
import com.chenyitun.cloudsystem.dao.LogDao;
import com.chenyitun.cloudsystem.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    LogDao logMapper;

//    @Async
    @Override
    public int save(SysLog sysLog) {
        return logMapper.save(sysLog);
    }

    @Async
    @Override
    public R saveLog(SysLog sysLog) {
        if(save(sysLog) > 0)
            return R.ok();
        return R.error();
    }

    @Override
    public List<SysLog> queryList(Query query) {
        List<SysLog> logs = logMapper.list(query);
        return logs;
    }

    @Override
    public int count(Query query) {
        return logMapper.count(query);
    }

    @Override
    public int remove(Long id) {
        int count = logMapper.remove(id);
        return count;
    }

    @Override
    public int batchRemove(Long[] ids) {
        return logMapper.batchRemove(ids);
    }
}
